<!DOCTYPE html>
<html>
<head>
    <title>消息管理</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="木兰湾管理系统">
    <script type="text/javascript" src="../../static/include/header-css.js"></script>
    <script type="text/javascript">

    </script>
</head>
<body>
<div class="weui-search-bar" id="searchBar">
    <form class="weui-search-bar__form" id="search-form">
        <div class="weui-search-bar__box">
            <i class="weui-icon-search"></i>
            <input type="search" class="weui-search-bar__input" id="searchInput" placeholder="搜索" name="name" required="" >
            <a href="javascript:searchData();" class="weui-icon-clear" id="searchClear"></a>
        </div>
        <label class="weui-search-bar__label" id="searchText">
            <i class="weui-icon-search"></i>
            <span>搜索</span>
        </label>
        <input type="hidden" name='page' value="1" id="page"/>
    </form>
    <a href="javascript:searchData()" class="mulanbay-search-btn" id="searchData">搜索</a>
</div>
<!--列表数据显示-->
<div id="dataContent"></div>
<!--滚动加载-->
<div class="weui-loadmore" id="loadingSpan">
    <span class="weui-loadmore__tips">加载中...</span>
</div>

<script type="text/javascript" src="../../static/include/footer-js.js"></script>
<script>
    $(function() {
        pushRefresh(getData);
        getData();
    });
    function showDelete(id) {
        var delUrlPrefix = '/userMessage/delete';
        commonDeleteByIds(delUrlPrefix,id,function () {
            //searchData();
            //直接把该节点删除
            setElementInnerHTML(getDivId(id),'');
        });
    }
    function searchData() {
        setPage(1);
        getData();
    }
    function getData() {
        var url = '/userMessage/getMyList';
        loadListData('search-form','dataContent','page',url,createRow,null);
    }
    function getDivId(id) {
        return 'UserMessage'+id;
    }
    function createRow(rowData) {
        var html='';
        html+='<div id="'+getDivId(rowData.id)+'">';
        html+='<div class="weui-form-preview">';
        if(rowData.url!=null){
            html+='    <a class="weui-cell  weui-cell_access weui-cell_example" href="'+rowData.url+'">\n';
        }else{
            html+='    <a class="weui-cell  weui-cell_access weui-cell_example" href="#">\n';
        }
        var pic = '<img src="../../static/image/message.png">';
        html+='        <div class="weui-cell__hd">'+pic+'</div>\n';
        html+='        <div class="weui-cell__bd">\n';
        html+='<label class="weui-form-preview__label">'+rowData.createdTime+'</label>';
        html+='        </div>\n';
        var status = '<font color="green">'+rowData.sendStatusName+'</font>'
        if(rowData.sendStatus=='UN_SEND'){
            status = '<font color="orange">'+rowData.sendStatusName+'</font>'
        }else if(rowData.sendStatus=='SEND_FAIL'){
            status = '<font color="red">'+rowData.sendStatusName+'</font>'
        }
        html+='        <div class="weui-cell__ft">'+status+'</div>\n';
        html+='    </a>\n';
        html+='    <div class="weui-form-preview__bd">\n';
        html+='        <div class="weui-form-preview__item">\n';
        html+='            <label class="weui-form-preview__label">期望发送时间</label>\n';
        html+='            <span class="weui-form-preview__value">'+rowData.expectSendTime+'</span>\n';
        html+='        </div>\n';
        html+='        <div class="weui-form-preview__item">\n';
        html+='            <label class="weui-form-preview__label">代码</label>\n';
        html+='            <span class="weui-form-preview__value">'+rowData.code+'</span>\n';
        html+='        </div>\n';
        html+='        <div class="weui-form-preview__item">\n';
        html+='            <label class="weui-form-preview__label">标题</label>\n';
        html+='            <span class="weui-form-preview__value mulanbay-dark-font">'+rowData.title+'</span>\n';
        html+='        </div>\n';
        html+='        <div class="weui-form-preview__item">\n';
        html+='            <label class="weui-form-preview__label">内容</label>\n';
        html+='            <span class="weui-form-preview__value mulanbay-dark-font">'+rowData.content+'</span>\n';
        html+='        </div>\n';
        html+='    </div>\n';
        html+='    <div class="weui-form-preview__ft">\n';
        html+='        <a class="weui-form-preview__btn weui-form-preview__btn_delete" href="javascript:showDelete('+rowData.id+');">删除</a>\n';
        html+='    </div>\n';
        html+='</div>\n';
        html+='</div>\n';
        html+='<br>\n';
        return html;
    }
</script>
</body>
</html>